package sk.naive.talker.props;

import sk.naive.talker.util.Utils;

import java.util.Set;

/**
 *
 * @author <a href="mailto:virgo@naive.deepblue.sk">Richard "Virgo" Richter</a>
 * @version $Revision: 1.6 $ $Date: 2005/01/18 20:51:30 $
 */
public class PropUtils {
	public static String completeValue(Property property, String value)	{
		String completed = null;
		if (value == null || value.length() == 0) {
			completed = (String) property.defaultValue();
		} else {
			Set<String> validValues = property.validValues();
			if (validValues != null) {
				completed = Utils.findFirstInCollection(value, validValues, true);
			}
		}
		if (completed == null) {
			return value;
		}
		return completed;
	}
}
